Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
archive-type
Advanced tools
The archive-type npm package is used to detect the type of archive file based on its buffer. It supports various archive formats such as zip, tar, rar, and more.
Detect Archive Type
This feature allows you to detect the type of an archive file by reading its buffer. The code sample reads a file into a buffer and then uses the archiveType function to determine the file type.
const archiveType = require('archive-type');
const fs = require('fs');
const buffer = fs.readFileSync('example.zip');
const type = archiveType(buffer);
console.log(type); // { ext: 'zip', mime: 'application/zip' }
The file-type package is used to detect the file type of a Buffer/Uint8Array/ArrayBuffer. It supports a wide range of file types, including archives, images, videos, and more. Compared to archive-type, file-type offers broader file type detection capabilities.
The detect-file-type package is another library for detecting file types from a buffer. It supports various file formats, including archives. While similar to archive-type, it also provides additional functionalities for detecting other file types.
Detect the archive type of a Buffer/Uint8Array
$ npm install --save archive-type
const archiveType = require('archive-type');
const readChunk = require('read-chunk');
const buffer = readChunk.sync('unicorn.zip', 0, 262);
archiveType(buffer);
//=> {ext: 'zip', mime: 'application/zip'}
Returns an Object
with:
ext
- One of the supported file typesmime
- The MIME typeOr null
when no match.
Type: Buffer
Uint8Array
It only needs the first 262 bytes.
7z
bz2
gz
rar
tar
zip
xz
gz
MIT © Kevin Mårtensson
FAQs
Detect the archive type of a Buffer/Uint8Array
The npm package archive-type receives a total of 1,927,484 weekly downloads. As such, archive-type popularity was classified as popular.
We found that archive-type demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.